package com.dada.tiku.web.controller;

import java.util.List;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.dubbo.config.annotation.Reference;
import com.alibaba.fastjson.JSON;
import com.dada.tiku.pojo.PaperCategory;
import com.dada.tiku.pojo.TPaper;
import com.dada.tiku.service.PaperService;


@RestController
public class PaperController {
	
	@Reference
	private PaperService paperService;
	
	//查找所有试卷列表
	@RequestMapping("paper/all")
	public String findAllPaper(@RequestParam(defaultValue="0")Integer start,@RequestParam(defaultValue="20")Integer count){
		List<TPaper> listPaper = paperService.findAllPaper(start,count);
		return JSON.toJSONString(listPaper);
	}
	
	//查找所有的题目类型列表
	@RequestMapping("/paper/typeList")
	public String findTypePaperList(){
		List<PaperCategory> list = paperService.findTypePaperList();
		return JSON.toJSONString(list);
	}
	
	//查找分类下的试卷集合--真题,模拟题,自测题等等
	@RequestMapping("/paper/type")
	public String findPaperByType(Integer typeid,@RequestParam(defaultValue="0")Integer start,@RequestParam(defaultValue="20")Integer count){
		List<TPaper> paperList = paperService.findListByType(typeid,start,count);
		String paperStr = JSON.toJSONString(paperList);
		return paperStr;
	}
	

}
